import json
import requests
from requests.adapters import HTTPAdapter

session = requests.Session()
session.mount('https://', HTTPAdapter(pool_connections=50, pool_maxsize=100))


class App():
    # scene_corresponding_table = {
    #   "default":"factorydefault"
    # }
    token = 'MIITwAYJKoZIhvcNAQcCoIITsTCCE60CAQExDTALBglghkgBZQMEAgEwghHSBgkqhkiG9w0BBwGgghHDBIIRv3sidG9rZW4iOnsiZXhwaXJlc19hdCI6IjIwMjMtMDEtMTJUMDg6MzA6MzcuNTIyMDAwWiIsIm1ldGhvZHMiOlsicGFzc3dvcmQiXSwiY2F0YWxvZyI6W10sInJvbGVzIjpbeyJuYW1lIjoiY2JzX2FkbSIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2Vjc19zcG90X2luc3RhbmNlIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfaXZhc192Y3JfdmNhIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfYV9jbi1zb3V0aC00YyIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2Vjc19rYWUxIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfS29vU2VhcmNoQ09CVCIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2R3c19wb2MiLCJpZCI6IjAifSx7Im5hbWUiOiJvcF9nYXRlZF9jYnJfZmlsZSIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2Vjc19rYzFfdXNlcl9kZWZpbmVkIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfbWVldGluZ19lbmRwb2ludF9idXkiLCJpZCI6IjAifSx7Im5hbWUiOiJvcF9nYXRlZF9tYXBfbmxwIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfZWdfY24iLCJpZCI6IjAifSx7Im5hbWUiOiJvcF9nYXRlZF9yZWRpczYtZ2VuZXJpYy1pbnRsIiwiaWQiOiIwIn0seyJuYW1lIjoib3Bf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A1UEBhMCQ04xEjAQBgNVBAgMCUd1YW5nRG9uZzERMA8GA1UEBwwIU2hlblpoZW4xLjAsBgNVBAoMJUh1YXdlaSBTb2Z0d2FyZSBUZWNobm9sb2dpZXMgQ28uLCBMdGQxDjAMBgNVBAsMBUNsb3VkMRMwEQYDVQQDDApjYS5pYW0ucGtpAgkA3LMrXRBhahAwCwYJYIZIAWUDBAIBMA0GCSqGSIb3DQEBAQUABIIBACxHbevzqLcWn1CZeuJa3lQbfmddV0qOlEY90JtxRr-+v5V2u+Fr5MNeFoF73aQ0MWSAtgRs2WxMyC2-DcS-pUqTso1cR1g6+DYl4n39e-QQGFcpds4lYNayYrknFdgUJMGT+Hc6I+evNbrc2nJNVIz5IHBpVYiKKN0lzcylr6Uct3OHrKJLt4jzYTuGPlROKOOKAR5gfqCF-WA7TJ2T0mc9NIxob4DaVQG8sEWEzqxHNyRJfSZpQ4BDZFEVpGDV-72i2C+r2LcIW65t8L-C8JqtSrQUHcS9AZ-BM1VK1UmHreOMOk2aUZjtgqPmziPxZ3Jxv+zyPS8ii8ciwJnsOYs='

    def __init__(self):
        pass

    def get_result(self, payload):

        # print( args['task'],type( args['task']))
        # print( args.get("task"),type(args.get("task")))
        # print(args.get("s2"),type(args.get("s2")))
        result = None
        try:

            #   print(payload,type(payload))
            # print(payload,type(payload))
            # 获取参数
            if payload:
                # 获取真实场景 默认factorydefault场景
                question = payload.get("question", "")
                user_id = payload.get("user_id", "")
                session_id = payload.get("session_id", "")
                msgdata = {
                    "question": question,
                    "user_id": user_id,
                    "session_id": session_id
                }

                qabot_id = 'b6fae42f-cae3-4039-81ba-cf7deb8cc67b'
                project_id = '0aff73dcc18026c72fc8c008d409da55'
                endpoint = 'cbs-ext.cn-north-4.myhuaweicloud.com'
                url = f"https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/chat"

                data = msgdata

                headers = {'Content-Type': 'application/json',
                           'X-Auth-Token': App.token}

                response = requests.post(
                    url, headers=headers, json=data, timeout=5, verify=False)

                result = json.loads(response.text)
                print(result, type(result))
                if result.get("error_code", "200") in ['APIG.0301']:
                    # token 过期 重新获取
                    token_kwargs = {
                        "auth": {
                            "identity": {
                                "methods": [
                                    "password"
                                ],
                                "password": {
                                    "user": {
                                        "name": "huawei_techhelp_cbs",
                                        "password": "kewosi.2023",
                                        "domain": {
                                            "name": "hw48427504"
                                        }
                                    }
                                }
                            },
                            "scope": {
                                "project": {
                                    "name": "cn-north-4"
                                }
                            }
                        }
                    }
                    token_headers = {'Content-Type': 'application/json'}
                    token_url = 'https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens'
                    token_to = 3
                    response = session.post(
                        token_url,
                        json=token_kwargs,
                        timeout=token_to,
                        headers=token_headers
                    )
                    print(response, type(response))

                    res = response.headers
                    App.token = res.get('X-Subject-Token', 'MIITwAYJKoZIhvcNAQcCoIITsTCCE60CAQExDTALBglghkgBZQMEAgEwghHSBgkqhkiG9w0BBwGgghHDBIIRv3sidG9rZW4iOnsiZXhwaXJlc19hdCI6IjIwMjMtMDEtMTBUMDk6NTA6NDQuOTI5MDAwWiIsIm1ldGhvZHMiOlsicGFzc3dvcmQiXSwiY2F0YWxvZyI6W10sInJvbGVzIjpbeyJuYW1lIjoiY2JzX2FkbSIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2Vjc19zcG90X2luc3RhbmNlIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfaXZhc192Y3JfdmNhIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfYV9jbi1zb3V0aC00YyIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2Vjc19rYWUxIiwiaWQiOiIwIn0seyJuYW1lIjoib3BfZ2F0ZWRfS29vU2VhcmNoQ09CVCIsImlkIjoiMCJ9LHsibmFtZSI6Im9wX2dhdGVkX2R3c19wb2MiLCJpZCI6IjAifSx7Im5hbWUiOiJvcF9nYXRlZF9jYnJfZmlsZSIsImlkIjoi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ZWRfYXQiOiIyMDIzLTAxLTA5VDA5OjUwOjQ0LjkyOTAwMFoiLCJ1c2VyIjp7ImRvbWFpbiI6eyJuYW1lIjoiaHc0ODQyNzUwNCIsImlkIjoiMDlhZTM3NGZlNzAwMjY4MjBmOGVjMDA4N2Q4NjkzMjAifSwibmFtZSI6Imh1YXdlaV90ZWNoaGVscF9jYnMiLCJwYXNzd29yZF9leHBpcmVzX2F0IjoiIiwiaWQiOiI4YWZjYzZlZmE0Nzk0NDNjOGVhMTg5MmE1NGYzYzZlYSJ9fX0xggHBMIIBvQIBATCBlzCBiTELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCUd1YW5nRG9uZzERMA8GA1UEBwwIU2hlblpoZW4xLjAsBgNVBAoMJUh1YXdlaSBTb2Z0d2FyZSBUZWNobm9sb2dpZXMgQ28uLCBMdGQxDjAMBgNVBAsMBUNsb3VkMRMwEQYDVQQDDApjYS5pYW0ucGtpAgkA3LMrXRBhahAwCwYJYIZIAWUDBAIBMA0GCSqGSIb3DQEBAQUABIIBAENu4CDVtEyvLYAcuAmtw2x5otTsUTMCBYtkfxVRFaDAlzDjXpkTNhRL6IC7GEzIHhbJqsFRx-y8c0g0g3vILzEAu0qzpxGZ4ENoOCc2BygOrVw8kc-3pkBYwj7dwZBnSH-auIavHe02vQJMO5q2yWImuW6HYN-DUvSpBR-CYVt1B+Ep9Rh9qlzPh94mM+PsnmmkgiG0QiI788T3JGuKUfXqH3AhxbeB-MYvKQxvGdrJm1-QjD28vQQ3g-twwLofv2+4PZj7ErvQ5HdY3EyY4TpG27XuGXZE0zp-cEhx5RNeCezMZjbyFhF4pZGCohcklpZmRi+y5QO2MpJL9H2PbDI=')
                    print(f'更新token{App.token}')

                    # 再次请求
                    headers = {'Content-Type': 'application/json',
                               'X-Auth-Token': App.token}
                    response = session.post(
                        url, headers=headers, json=data, timeout=5, verify=False)

                    result = json.loads(response.text)
                    print(result, type(result))
        except Exception as e:

            print(e)
            result = {"rusult": "Invalid input"}
            return result
        return result


if __name__ == "__main__":
    app = App()
    payload = {
        "question": "春节是那一天",
        "user_id": 'test',
        "session_id": "91084ddb-1d59-42ac-f4b6-8182f157b5f1"
    }
    r = app.get_result(payload)
    print(json.dumps(r))
